package com.dailycodebuffer.springbootmongodb.service;

import com.dailycodebuffer.springbootmongodb.collection.Orders;
import com.dailycodebuffer.springbootmongodb.repository.OrdersRepository;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;


/**
 * 业务层
 *
 * @author makejava
 * @since 2025-01-04 00:23:42
 */
@Service
public class OrdersServiceImpl implements OrdersService {

	@Resource
    private OrdersRepository ordersRepository;

    @Override
    public void save(Orders orders) {
        ordersRepository.save(orders);
    }


    @Override
    public Orders findById(Integer id) {
        return ordersRepository.findById(id).orElse(null);
    }

//    @Override
//    public List<Orders> findById(Collection<Integer> ids) {
//        Iterable<Orders> iterable = ordersRepository.findAll(ids);
//        return StreamSupport.stream(iterable.spliterator(), false)
//                .collect(Collectors.toList());
//    }

    @Override
    public Page<Orders> list(Pageable page) {
        return ordersRepository.findAll(page);
    }

}

